package com.atguigu.gmall.item.controller;

import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.item.service.ItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;
import java.util.Objects;

/**
 * @author: atguigu
 * @create: 2023-07-28 16:29
 */
@RestController
@RequestMapping("/api/item")
public class ItemController {


    @Autowired
    private ItemService itemService;

    /**
     * 汇总渲染详情页面所需要数据模型
     *
     * @param skuId
     * @return
     */
    @GetMapping("/{skuId}")
    public Result<Map> getItemInfo(@PathVariable("skuId") Long skuId) {
        Map<String, Object> mapResult = itemService.getItemInfo(skuId);
        return Result.ok(mapResult);
    }
}
